HAL RCC Function services

This subsection provides a set of functions allowing to control the activation or deactivation of MSI PLL-mode, LSE CSS, Low speed clock output and clock after wake-up from STOP mode.

Clock Security system management (LSECSS)

Function Description

The HAL_RCCEx_EnableLSECSS and HAL_RCCEx_DisableLSECSS functions are used to enable and disable the Low-Speed External Clock Security System (LSECSS).

HAL1

HAL2

Function name

void HAL_RCCEx_EnableLSECSS(void);

void HAL_RCC_LSE_EnableCSS(void);

Function name

void HAL_RCCEx_DisableLSECSS(void);

void HAL_RCC_LSE_DisableCSS(void);

Example Usage

HAL1

HAL2

HAL_RCCEx_EnableLSECSS();

HAL_RCCEx_DisableLSECSS();
HAL_RCC_LSE_EnableCSS();

HAL_RCC_LSE_DisableCSS();

RCC LSE Clock Security System interrupt request

Function Description

The HAL_RCCEx_LSECSS_IRQHandler and HAL_RCCEx_LSECSS_Callback functions handle the interrupt and callback for the Low-Speed External Clock Security System (LSECSS).

HAL1

HAL2

Function name

void HAL_RCCEx_LSECSS_IRQHandler(void);

void HAL_RCC_LSECSS_IRQHandler(void);

Function name

void HAL_RCCEx_LSECSS_Callback(void);

void HAL_RCC_LSE_CSSCallback(void);

Example Usage

HAL1

HAL2

HAL_RCCEx_LSECSS_IRQHandler();

HAL_RCCEx_LSECSS_Callback();
HAL_RCC_LSECSS_IRQHandler();

HAL_RCC_LSE_CSSCallback();

MSI PLL unlock interrupt

Function Description

The HAL_RCCEx_MSIPLLUNLCK_IRQHandler and HAL_RCCEx_MSIPLLUNLCK_Callback functions handle the interrupt and callback for the MSI PLL Unlock event.

HAL1

HAL2

Function name

void HAL_RCCEx_MSIPLLUNLCK_IRQHandler(void);

void HAL_RCC_MSI_PLLUnlock_IRQHandler(void);

Function name

void HAL_RCCEx_MSIPLLUNLCK_Callback(void);

void HAL_RCC_MSI_PLLUnlock_Callback(void);

Example Usage

HAL1

HAL2

HAL_RCCEx_MSIPLLUNLCK_IRQHandler();

HAL_RCCEx_MSIPLLUNLCK_Callback();
HAL_RCC_MSI_PLLUnlock_IRQHandler();

HAL_RCC_MSI_PLLUnlock_Callback();

Low Speed clock LSCO

Function Description

The HAL_RCCEx_EnableLSCO and HAL_RCCEx_DisableLSCO functions are used to enable and disable the Low-Speed Clock Output (LSCO).

HAL1

HAL2

Function name

void HAL_RCCEx_EnableLSCO(uint32_t LSCOSource);

hal_status_t HAL_RCC_EnableLSCO(hal_rcc_lsco_src_t source);

Function name

void HAL_RCCEx_DisableLSCO(void);

hal_status_t HAL_RCC_DisableLSCO(void);

Example Usage

HAL1

HAL2

HAL_RCCEx_EnableLSCO(RCC_LSCOSOURCE_LSI);

HAL_RCCEx_DisableLSCO();
hal_status_t status;

status = HAL_RCC_EnableLSCO(HAL_RCC_LSCOSOURCE_LSI);

status = HAL_RCC_DisableLSCO();

PLL-mode of the MSI

Function Description

The HAL_RCCEx_EnableMSIPLLMode and HAL_RCCEx_DisableMSIPLLMode functions are used to enable and disable the MSI PLL mode.

HAL1

HAL2

Function name

void HAL_RCCEx_EnableMSIPLLMode(void);

hal_status_t HAL_RCC_MSI_EnablePLLMode(void);

Function name

void HAL_RCCEx_DisableMSIPLLMode(void);

void HAL_RCC_MSI_DisablePLLMode(void);

Example Usage

HAL1

HAL2

HAL_RCCEx_EnableMSIPLLMode();

HAL_RCCEx_DisableMSIPLLMode();
hal_status_t status;

status = HAL_RCC_MSI_EnablePLLMode();

HAL_RCC_MSI_DisablePLLMode();

Configure the MSI range after standby mode

Function Description

The HAL_RCCEx_StandbyMSIRangeConfig and HAL_RCCEx_StandbyMSIKRangeConfig functions are used to configure the standby MSI and MSIK range.

HAL1

HAL2

Function name

void HAL_RCCEx_StandbyMSIRangeConfig(uint32_t MSIRange);

void HAL_RCC_ MSIS_SetStandbyRange(hal_rcc_msirange_t msi_range);

Function name

void HAL_RCCEx_StandbyMSIKRangeConfig(uint32_t MSIKRange);

void HAL_RCC_ MSIK_SetStandbyRange(hal_rcc_msik_src_t msikRange);

Example Usage

HAL1

HAL2

uint32_t msi_range = RCC_MSIRANGE_4;
HAL_RCCEx_StandbyMSIRangeConfig(msi_range);

uint32_t msik_range = RCC_MSIKRANGE_4;
HAL_RCCEx_StandbyMSIKRangeConfig(msi_range);
uint32_t msi_range = HAL_RCC_MSIS_RANGE_4;
HAL_RCC_MSIS_SetRange(msi_range);

uint32_t msik_range = HAL_RCC_MSIK_RANGE_4;
HAL_RCC_MSIK_SetStandbyRange(msik_range);

MSI output clock uses the PLL mode

Function Description

The HAL_RCCEx_EnableMSIPLLModeSelection function is used to enable the selection of MSI PLL mode.

HAL1

HAL2

Function name

HAL_StatusTypeDef HAL_RCCEx_EnableMSIPLLModeSelection(uint32_t MSIPLLModeSelection);

hal_status_t HAL_RCC_MSI_EnablePLLModeSelection(hal_rcc_msi_pll_mode_sel_t msipll_mode_selection);

Example Usage

HAL1

HAL2

HAL_StatusTypeDef status;
uint32_t msipll_mode_selection = RCC_MSIPLLMODE_SELECTION;

status = HAL_RCCEx_EnableMSIPLLModeSelection(msipll_mode_selection);
hal_status_t status;
hal_rcc_msi_pll_mode_sel_t msipll_mode_selection = HAL_RCC_MSI_PLLMODE_SELECTION;

status = HAL_RCC_MSI_EnablePLLModeSelection(msipll_mode_selection);

MSI PLL fast startup Enable/Disable

Function Description

The HAL_RCCEx_EnableMSIPLLFastStartup and HAL_RCCEx_DisableMSIPLLFastStartup functions are used to enable and disable the MSI PLL fast startup feature.

HAL1

HAL2

Function name

HAL_StatusTypeDef HAL_RCCEx_EnableMSIPLLFastStartup(void);

hal_status_t HAL_RCC_MSI_EnablePLLFastStartup(void);

Function name

HAL_StatusTypeDef HAL_RCCEx_DisableMSIPLLFastStartup(void);

hal_status_t HAL_RCC_MSI_DisablePLLFastStartup(void);

Example Usage

HAL1

HAL2

HAL_StatusTypeDef status;

status = HAL_RCCEx_EnableMSIPLLFastStartup();

status = HAL_RCCEx_DisableMSIPLLFastStartup();
hal_status_t status;

status = HAL_RCC_MSI_EnablePLLFastStartup();

status = HAL_RCC_MSI_DisablePLLFastStartup();

Oscillator clock source configuration for wakeup from Stop and CSS backup clock

Function Description

The HAL_RCCEx_WakeUpStopCLKConfig and HAL_RCCEx_KerWakeUpStopCLKConfig functions are used to configure the clock settings after waking up from stop mode. In HAL2, these functions have been renamed, and two new functions have been added to retrieve the current configuration.

HAL1

HAL2

Function name

void HAL_RCCEx_WakeUpStopCLKConfig(uint32_t WakeUpClk);

void HAL_RCC_SetClockAfterWakeFromStop(hal_rcc_stop_wakeup_clk_t wakeup_clk);

Function name

void HAL_RCCEx_KerWakeUpStopCLKConfig(uint32_t WakeUpClk);

void HAL_RCC_SetKernelClkAfterWakeFromStop(hal_rcc_stop_wakeup_kerclk_t wakeup_clk);

New Function

N/A

hal_rcc_stop_wakeup_clk_t HAL_RCC_GetClockAfterWakeFromStop(void);

New Function

N/A

hal_rcc_stop_wakeup_kerclk_t HAL_RCC_GetKernelClkAfterWakeFromStop(void);

Example Usage

HAL1

HAL2

uint32_t wakeup_clk = RCC_WAKEUPSTOPCLK_MSI;
HAL_RCCEx_WakeUpStopCLKConfig(wakeup_clk);


uint32_t ker_wakeup_clk = RCC_WAKEUPSTOPCLK_MSI;
HAL_RCCEx_KerWakeUpStopCLKConfig(ker_wakeup_clk);
hal_rcc_stop_wakeup_clk_t wakeup_clk = HAL_RCC_STOP_WAKEUP_CLK_MSI;
HAL_RCC_SetClockAfterWakeFromStop(wakeup_clk);


hal_rcc_stop_wakeup_kerclk_t ker_wakeup_clk = HAL_RCC_STOP_WAKEUP_KERCLK_MSI;
HAL_RCC_SetKernelClkAfterWakeFromStop(ker_wakeup_clk);


wakeup_clk = HAL_RCC_GetClockAfterWakeFromStop();


ker_wakeup_clk = HAL_RCC_GetKernelClkAfterWakeFromStop();

HAL RCC MCO configuration

Function Description

The HAL_RCC_MCOConfig function is used to configure the Microcontroller Clock Output (MCO). In HAL2, this function has been renamed to HAL_RCC_SetConfigMCO with updated parameter types.

HAL1

HAL2

Function name

void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv);

void HAL_RCC_SetConfigMCO(hal_rcc_mco_src_t mco_src, hal_rcc_mco_div_t mco_div);

Example Usage

HAL1

HAL2

HAL_RCC_MCOConfig(RCC_MCO1, RCC_MCOSOURCE_HSI, RCC_MCODIV_1);
HAL_RCC_SetConfigMCO(HAL_RCC_MCO_SRC_HSI, HAL_RCC_MCO_PRESCALER_1);

RCC Clock Security System interrupt enable

Function Description

The HAL_RCCEx_EnableLSECSS_IT function is used to enable the LSE Clock Security System Interrupt & corresponding EXTI line.

HAL1

HAL2

Function name

void HAL_RCCEx_EnableLSECSS_IT(void);

New sequence

Example Usage

HAL1

HAL2

HAL_RCCEx_EnableLSECSS_IT();
LL_RCC_LSE_EnableCSS();
LL_EXTI_EnableIT_0_31(LL_EXTI_LINE_13);
LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_13);

RCC Clock Security System interrupt request

Function Description

The HAL_RCC_EnableCSS, HAL_RCC_CSSCallback, and HAL_RCC_NMI_IRQHandler functions are used to manage the Clock Security System (CSS) and Non-Maskable Interrupt (NMI) handling. In HAL2, the CSS-related functions have been renamed to focus specifically on the High-Speed External (HSE) clock.

HAL1

HAL2

Function name

void HAL_RCC_EnableCSS(void);

void HAL_RCC_HSE_EnableCSS(void);

Function name

void HAL_RCC_CSSCallback(void);

hal_status_t HAL_RCC_HSE_CSSCallback(void);

Function name

void HAL_RCC_NMI_IRQHandler(void);

hal_status_t HAL_RCC_NMI_IRQHandler(void);

Example Usage

HAL1

HAL2

HAL_RCC_EnableCSS();
HAL_RCC_CSSCallback();
HAL_RCC_NMI_IRQHandler();
HAL_RCC_HSE_EnableCSS();
hal_status_t status =  HAL_RCC_HSE_CSSCallback();
hal_status_t status =  HAL_RCC_NMI_IRQHandler();

RCC Clock Security System interrupt enable

Function Description

The HAL_RCCEx_EnableMSIPLLUNLCK_IT function is used to enable the MSI PLL Unlock Interrupt & corresponding EXTI line.

HAL1

HAL2

Function name

void HAL_RCCEx_EnableMSIPLLUNLCK_IT(void);

New sequence

Example Usage

HAL1

HAL2

HAL_RCCEx_EnableMSIPLLUNLCK_IT();
LL_EXTI_EnableIT_0_31(LL_EXTI_LINE_13);
LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_13);

Note

To identify the line on which the LL_EXTI_LINE_xx feature is available in STM32 series, please refer to the reference manual EXTI section.


HAL RCC Clock Security System interrupt enable

Function Description

The HAL_RCCEx_MSIPLLUNLCK_IRQHandler function is used to Handle the RCC MSI PLL Unlock interrupt request.

HAL1

HAL2

Function name

void HAL_RCCEx_MSIPLLUNLCK_IRQHandler(void);

New sequence

Example Usage

HAL1

HAL2

HAL_RCCEx_MSIPLLUNLCK_IRQHandler();
LL_EXTI_ClearRisingFlag_0_31(LL_EXTI_LINE_13);
LL_EXTI_ClearFallingFlag_0_31(LL_EXTI_LINE_13);
HAL_RCC_MSI_PLLUnlock_IRQHandler();

Note

To identify the line on which the LL_EXTI_LINE_xx feature is available in STM32 series, please refer to the reference manual EXTI section.